# 配置哨兵列表
REDIS_SENTINELS = [
        ('127.0.0.1', '26380'),
        ('127.0.0.1', '26381'),
        ('127.0.0.1', '26382'),
]
REDIS_SENTINEL_SERVICE_NAME = 'mymaster'

# 使用哨兵返回redis服务器对象
from redis.sentinel import Sentinel
# 创建哨兵对象
_sentinel = Sentinel(REDIS_SENTINELS)
# 使用哨兵对象返回master redis服务对象
redis_master = _sentinel.master_for(REDIS_SENTINEL_SERVICE_NAME)
# 使用哨兵对象返回slave redis服务对象
redis_slave = _sentinel.slave_for(REDIS_SENTINEL_SERVICE_NAME)

# redis_master.set('a', 100)
print(redis_slave.get('a'))